package com.moleq.models;

import com.moleq.db.DatabaseSchema;

import android.R.integer;

public class ItemSetting {

	private String upc; // F01
	private String name; // F02
	private int dep; // F03
	private int subDep; // F04
	private String active; // F08
	private int casePack; // F19
	private String netWT; // F23
	private String netWtText; // F23Text
	private double wt; // F24
	private String vendor; // F27
	private String desc; // F29
	private Double price; // F30
	private int multple; // F31
	private Double caseCost; // F38
	private String foodStamp; // F79
	private String tax1; // F81
	private String scaleWeight; // F82
	private String wic; // F178
	private String cvv; // F924
	private String create_datetime; // create_datetime
	private String update_datetime; // update_datetime
	private String followdep; // F106
	private String tax2; // F96
	private String tax3; // F97
	private String tax4; // F98
	private String item_discount_flag; // F150
	private String bottle_deposit; // F158
	private String is_loyalty; // is_loyalty
	private int is_tare; // is_tare
	private String is_age_ver; // is_age_ver
	private String tax5; // F99
	private String tax6; // F100
	private String is_coupon; // is_coupon
	private String service_fl; //service_fl
	private String printer_id; //printer_id
	private String is_mult_coupon;//is_mult_coupon

	public String getFollowdep() {
		return followdep;
	}

	public Boolean getFollowdepCheckBox() {
		if (this.followdep.equals("1")) {
			return true;
		}
		return false;
	}

	public void setFollowdep(String followdep) {
		this.followdep = followdep;
	}

	public ItemSetting() {
	}

	public String getUpc() {
		return upc;
	}

	public void setUpc(String upc) {
		this.upc = upc;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getDep() {
		return dep;
	}

	public void setDep(int dep) {
		this.dep = dep;
	}

	public int getSubDep() {
		return subDep;
	}

	public void setSubDep(int subDep) {
		this.subDep = -1;
	}

	public void setSubDep(String subDep) {
		if (subDep == null || subDep.equals("")) {
			this.subDep = -1;
		} else {
			this.subDep = Integer.valueOf(subDep);
		}
	}

	public String getActive() {
		return active;
	}

	public boolean getActiveCheckBox() {
		if (active.equals("A")) {
			return true;
		} else {
			return false;
		}
	}

	public void setActive(String active) {
		this.active = active;
	}

	public void setActive(boolean active) {
		if (active) {
			this.active = "A";
		} else {
			this.active = "N";
		}
	}

	public int getCasePack() {
		return casePack;
	}

	public void setCasePack(int casePack) {
		this.casePack = -1;
	}

	public void setCasePack(String casePack) {
		if (casePack == null || casePack.equals("")) {
			this.casePack = -1;
		} else {
			this.casePack = Integer.valueOf(casePack);
		}
	}

	public String getNetWT() {
		return netWT;
	}

	public void setNetWT(String netWT) {
		this.netWT = netWT;
	}

	public double getWt() {
		if (wt <= 0) {
			return 0;
		}
		return wt;
	}

	public void setWt(double wt) {
		this.wt = wt;
	}

	public void setWt(String wt) {
		if (wt.equals("")) {
			this.wt = 0;
		} else {
			this.wt = Double.valueOf(wt);
		}
	}

	public String getVendor() {
		return vendor;
	}

	public void setVendor(String vendor) {
		this.vendor = vendor;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public int getMultple() {
		return multple;
	}

	public String getMultpleText() {
		if (multple < 2) {
			return "";
		} else {
			return String.valueOf(multple);
		}
	}

	public void setMultple(int multple) {
		this.multple = multple;
	}

	public void setMultple(String multple) {
		if (multple.equals("")) {
			this.multple = 1;
		} else {
			this.multple = Integer.valueOf(multple);
		}
	}

	public Double getCaseCost() {
		return caseCost;
	}

	public void setCaseCost(Double caseCost) {
		this.caseCost = -1.0;
	}

	public void setCaseCost(String caseCost) {
		if (caseCost.equals("")) {
			this.caseCost = Double.valueOf(-1);
		} else {
			this.caseCost = Double.valueOf(caseCost);
		}
	}

	public String getFoodStamp() {
		return foodStamp;
	}

	public void setFoodStamp(String foodStamp) {
		this.foodStamp = foodStamp;
	}

	public boolean getFoodStampCheckBox() {
		if (foodStamp.equals("1")) {
			return true;
		} else {
			return false;
		}
	}

	public String getScaleWeight() {
		return scaleWeight;
	}

	public boolean getScaleWeightCheckBox() {
		if (scaleWeight.equals("1")) {
			return true;
		} else {
			return false;
		}
	}

	public void setScaleWeight(String scaleWeight) {
		this.scaleWeight = scaleWeight;
	}

	public String getWic() {
		return wic;
	}

	public boolean getWicCheckBox() {
		if (wic.equals("1")) {
			return true;
		} else {
			return false;
		}
	}

	public void setWic(String wic) {
		this.wic = wic;
	}

	public String getCvv() {
		return cvv;
	}

	public boolean getCvvCheckBox() {
		if (cvv.equals("1")) {
			return true;
		} else {
			return false;
		}
	}

	public void setCvv(String cvv) {
		this.cvv = cvv;
	}

	public String getTax1() {
		return tax1;
	}

	public boolean getTax1CheckBox() {
		if (this.tax1.equals("1")) {
			return true;
		}
		return false;
	}

	public void setTax1(String tax1) {
		this.tax1 = tax1;
	}

	public String getTax2() {
		return tax2;
	}

	public boolean getTax2CheckBox() {
		if (this.tax2.equals("1")) {
			return true;
		}
		return false;
	}

	public void setTax2(String tax2) {
		this.tax2 = tax2;
	}

	public String getTax3() {
		return tax3;
	}

	public boolean getTax3CheckBox() {
		if (this.tax3.equals("1")) {
			return true;
		}
		return false;
	}

	public void setTax3(String tax3) {
		this.tax3 = tax3;
	}

	public String getTax4() {
		return tax4;
	}

	public boolean getTax4CheckBox() {
		if (this.tax4.equals("1")) {
			return true;
		}
		return false;
	}

	public void setTax4(String tax4) {
		this.tax4 = tax4;
	}

	public String getTax5() {
		return tax5;
	}

	public boolean getTax5CheckBox() {
		if (this.tax5.equals("1")) {
			return true;
		}
		return false;
	}

	public void setTax5(String tax5) {
		this.tax5 = tax5;
	}

	public String getTax6() {
		return tax6;
	}

	public boolean getTax6CheckBox() {
		if (this.tax6.equals("1")) {
			return true;
		}
		return false;
	}

	public void setTax6(String tax6) {
		this.tax6 = tax6;
	}

	public String getItem_discount_flag() {
		return item_discount_flag;
	}

	public boolean getItem_discount_flagCheckBox() {
		if (this.item_discount_flag.equals("1")) {
			return true;
		}
		return false;
	}

	public void setItem_discount_flag(String item_discount_flag) {
		this.item_discount_flag = item_discount_flag;
	}

	public String getBottle_deposit() {
		return bottle_deposit;
	}

	public boolean getBottle_depositCheckBox() {
		if (Integer.valueOf(bottle_deposit) > 0) {
			return true;
		} else {
			return false;
		}
	}

	public void setBottle_deposit(String bottle_deposit) {
		this.bottle_deposit = bottle_deposit;
	}

	public String getIs_age_ver() {
		return is_age_ver;
	}

	public boolean getIs_age_verCheckBox() {
		if (Integer.valueOf(this.is_age_ver) > 0) {
			return true;
		}
		return false;
	}

	public void setIs_age_ver(String is_age_ver) {
		this.is_age_ver = is_age_ver;
	}

	public String getIs_loyalty() {
		return is_loyalty;
	}

	public boolean getIs_loyaltyCheckBox() {
		if (this.is_loyalty.equals("1")) {
			return true;
		}
		return false;
	}

	public void setIs_loyalty(String is_loyalty) {
		this.is_loyalty = is_loyalty;
	}

	public String getCreate_datetime() {
		return create_datetime;
	}

	public void setCreate_datetime(String create_datetime) {
		this.create_datetime = create_datetime;
	}

	public String getUpdate_datetime() {
		return update_datetime;
	}

	public void setUpdate_datetime(String update_datetime) {
		this.update_datetime = update_datetime;
	}

	public int getIs_tare() {
		return is_tare;
	}

	public void setIs_tare(int is_tare) {
		this.is_tare = is_tare;
	}

	public String getIs_coupon() {
		return is_coupon;
	}

	public boolean getIs_couponCheckBox() {
		if (is_coupon.equals("1")) {
			return true;
		} else {
			return false;
		}
	}

	public void setIs_coupon(String is_coupon) {
		this.is_coupon = is_coupon;
	}

	public String getNetWtText() {
		return netWtText;
	}

	public void setNetWtText(String netWtText) {
		this.netWtText = netWtText;
	}

	public String getService_fl() {
		return service_fl;
	}
	
	public boolean getService_CheckBox(){
		if(service_fl.equals("0")){
			return false;
		}else{
			return true;
		}
	}

	public void setService_fl(String service_fl) {
		this.service_fl = service_fl;
	}
	
	public void serService_fl(boolean service_fl){
		if(service_fl){
			this.service_fl = "1";
		}else{
			this.service_fl = "0";
		}
	}

	public String getPrinter_id() {
		return printer_id;
	}

	public void setPrinter_id(String printer_id) {
		this.printer_id = printer_id;
	} 
	
	public String getIs_mult_coupon() {
		return is_mult_coupon;
	}

	public void setIs_mult_coupon(String is_mult_coupon) {
		this.is_mult_coupon = is_mult_coupon;
	}
	
	public boolean getIs_mult_coupon_CheckBox(){
		if(is_mult_coupon.equals("0")){
			return false;
		}else{
			return true;
		}
	}

	public String toMGData(String Action) {
		String Result = Action + "|" + DatabaseSchema.ItemSetting.SCHEMA_NAME
				+ "|(" + CheckNull(getUpc()) + "," + CheckSign(CheckNull(getName())) + ","
				+ getDep() + "," + (getSubDep() == -1?null:getSubDep()) + "," + CheckNull(getActive())
				+ "," + (getCasePack() == -1?null:getCasePack()) + "," + CheckNull(getNetWT()) + ","
				+ getWt() + "," + CheckNull(getVendor()) + ","
				+ CheckSign(CheckNull(getDesc())) + "," + getPrice() + "," + getMultple()
				+ "," + (getCaseCost() == -1?null:getCaseCost()) + "," + CheckNull(getFoodStamp()) + ","
				+ CheckNull(getTax1()) + "," + CheckNull(getScaleWeight())
				+ "," + CheckNull(getWic()) + "," + CheckNull(getCvv()) + ","
				+ CheckNull(getCreate_datetime()) + ","
				+ CheckNull(getUpdate_datetime()) + ","
				+ CheckNull(getFollowdep()) + "," + CheckNull(getTax2()) + ","
				+ CheckNull(getTax3()) + "," + CheckNull(getTax4()) + ","
				+ CheckNull(getItem_discount_flag()) + ","
				+ CheckNull(getBottle_deposit()) + ","
				+ CheckNull(getIs_loyalty()) + "," + getIs_tare() + ","
				+ CheckNull(getIs_age_ver()) + "," + CheckNull(getTax5()) + ","
				+ CheckNull(getTax6()) + "," + CheckNull(getIs_coupon()) + "," + CheckNull(getService_fl()) + "," + getPrinter_id() + "," + CheckNull(getIs_mult_coupon()) + ")";
		return Result;
	}
	
	public String toMGData(String Action,String priceString,int depno) {
		String Result = Action + "|" + DatabaseSchema.ItemSetting.SCHEMA_NAME
				+ "|(" +priceString+","+depno+ ")";
		return Result;
	}

	public String CheckNull(String value) {
		if (value == null) {
			return null;
		} else {
			return "'" + value + "'";
		}
	}
	
	public String CheckSign(String str){
		if(str == null) return null;
		String data = str.substring(1, (str.length() - 1));
		String result = "";
		for (int i = 0; i < data.length(); i++) {
			String charString = String.valueOf(data.charAt(i));
			if(charString.equals("'")){
				result += charString + "'";
			}else{
				result += charString;
			}
		}
		
		return "'" + result + "'";
	}
}
